package com.kafka.danYiMessage.shoudong;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * 作者: LCG
 * 日期: 2020/6/19 23:27
 * 描述: 手动提交KafKa消费的偏移量
 */
@Component
public class ShouDongRecive {

    @KafkaListener(containerFactory = "kafkaListenerContainerFactory" ,topics = {"TTTT"},groupId = "TG01")
    public void cccc(ConsumerRecord<String,String> consumerRecords, Acknowledgment ack){

        String value = consumerRecords.value();
        System.out.println("=========="+value);
        //确认偏移量(如果不做确认的话会导致消息的重复消费)
        ack.acknowledge();

    }

}
